package com.ygo.feihua;
import android.app.ProgressDialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.GridView;
import android.widget.TextView;
import android.widget.Toast;
import cn.bmob.v3.BmobQuery;
import cn.bmob.v3.listener.FindListener;
import com.ygo.feihua.BmobTable.Zhuti;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.view.View.OnClickListener;
import android.view.View;
import cn.bmob.v3.exception.BmobException;
import com.ygo.feihua.util.*;

public class ZhutiZhuxian extends AppCompatActivity
{
	
	List<Zhuti>list;
	TextView zt_bt1;
	Gongju gj;
	DialogUtils du;
	
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		// TODO: Implement this method
		super.onCreate(savedInstanceState);
		 
		setContentView(R.layout.zhuti_zhuxian);
        gj=Gongju.getdx(this);
		du=DialogUtils.getdx(this);
		Intent intent = this.getIntent();
		String ztid = intent.getStringExtra("zt");
		zt_bt1=(TextView) findViewById(R.id.zt_bt1);
		zt_bt1.setText("主题:"+ztid);
		gv(ztid);
	}
	//表格布局初始化
	public void gv(final String ss){
		du.dialogj1(false,"","搜索中,请稍等");
		BmobQuery<Zhuti> zt=new BmobQuery<Zhuti>();
		zt.addWhereEqualTo("ztname",ss);
		zt.addWhereEqualTo("ztsh",1);	
		zt.addWhereEqualTo("vercode",Gongju.ZHUTI_VERCODE);
		zt.findObjects(new FindListener<Zhuti>(){

				@Override
				public void done(List<Zhuti> p1, BmobException p2)
				{
					if(p2==null){
						if(p1.size()==0){
							gj.show("没有这个主题");
						}else{
							list=p1;
						}
						du.dis();
						GridView gv=(GridView) findViewById(R.id.zt_zt);
						gv.setAdapter(new gvitem(ZhutiZhuxian.this,list));
					}else{
						gj.show("搜索失败"+p2);
						du.dis();
						
					}
					// TODO: Implement this method
				}
			});
			
		}
		
	
	
	
}
